package com.sc.adminspringboot.dao;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sc.adminspringboot.dto.TagInfo;
import com.sc.adminspringboot.pojo.Tags;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Carson
 * @since 2025-09-22 04:46:00
 */
public interface ITagsDao extends BaseMapper<Tags> {
    @Select("SELECT up.preference_id as id, t.tag_name as tagName, t.type, up.user_id as relatedId, up.click_time as clickTime, up.tag_id as tagId " +
            "FROM user_preferences up " +
            "LEFT JOIN tags t ON up.tag_id = t.id " +
            "ORDER BY up.click_time DESC")
    IPage<TagInfo> selectPreferTagsWithPage(IPage<TagInfo> page);


    @Select("SELECT pt.id as id, t.tag_name as tagName, t.type, pt.post_id as relatedId, pt.clicktime as clickTime, pt.id as associationId " +
            "FROM post_tags pt " +
            "LEFT JOIN tags t ON pt.tag_id = t.id " +
            "ORDER BY pt.clicktime DESC")
    IPage<TagInfo> selectPostTagsWithPage(IPage<TagInfo> page);


}
